//
//  ViewController.m
//  Lazy
//
//  Created by Echo on 14-4-1.
//  Copyright (c) 2014年 Echo. All rights reserved.
//

#import "ViewController.h"
#import "GoodBtn.h"
#import "GoodLabel.h"
#import "WsHUD.h"
#import "NewWifiViewController.h"
#import "DeviceInfoViewController.h"
#import "DeviceListViewController.h"

NSString * const Characteristic_HeartRateControlPoint_UUID = @"2A39";

@interface ViewController (){
    UITableView *tabview;
}
@end

@implementation ViewController
//0406513F9E   3F9E0651 1.23  1067320896.000000
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
//        float fdas = 0x00000000000000000000003F9E0651;
//        //4294967296.000000 281474976710656.000000
//        NSLog(@"%f", fdas);
//        NSLog(@"%f", fdas);
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    
//    self.title = STR(@"主页");
    
//    tabview = [[UITableView alloc] init];
//    tabview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"iphone5_bg.png"]];
////    tabview.backgroundColor = [UIColor redColor];
//    tabview.separatorColor = [UIColor whiteColor];
//    tabview.delegate = self;
//    tabview.dataSource = self;
//    tabview.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64);
//    [self.view addSubview:tabview];
//    
    DeviceListViewController *view = [[DeviceListViewController alloc] init];
    [self.navigationController pushViewController:view animated:YES];

}

- (void)viewDidAppear:(BOOL)animated {
//    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewDidAppear:animated];
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 64;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"TableView1Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.textLabel.font = [UIFont systemFontOfSize:17];
    cell.textLabel.textColor = [UIColor whiteColor];
    cell.textLabel.textAlignment = UITextAlignmentCenter;
    cell.backgroundColor = [UIColor clearColor];
    if (indexPath.row == 0) {
        for (int i=0; i<2; i++) {
            GoodBtn *btn = [GoodBtn btnWithFont:20];
            btn.frame = CGRectMake(35, 5, 100, 64);
            btn.titleLabel.font = [UIFont boldSystemFontOfSize:20];
            [btn setTitle:@"仪表列表" forState:UIControlStateNormal];
            [btn setTitleColor:RGB(255, 255, 255, 1) forState:UIControlStateNormal];
            if (i == 1) {
                btn.frame = CGRectMake(FX(btn)+150, FY(btn), 100, 64);
                [btn setTitle:@"扫瞄" forState:UIControlStateNormal];
            }
            [cell.contentView addSubview:btn];
        }
    }else if(indexPath.row == 4){
        cell.textLabel.font = [UIFont boldSystemFontOfSize:22];
//        cell.textLabel.text = @"添加新设备";
        
        UIButton *button = [[UIButton alloc] init];
        [button addTarget:self action:@selector(buttonPressed) forControlEvents:UIControlEventTouchUpInside];
        button.frame = CGRectMake(0, 0, 320, 64);
        [button setImage:IMG(@"new_device.png") forState:UIControlStateNormal];
        [cell.contentView addSubview:button];
        
    }else{
        
//        UIView *view = [[UIView alloc] init];
//        view.backgroundColor = RGB(0, 105, 235, 1);
//        view.frame = CGRectMake(0, 0, 320, 63);
//        [cell.contentView addSubview:view];
        cell.backgroundColor = RGB(0, 105, 235, 1);
        
        cell.textLabel.textColor = [UIColor whiteColor];
        cell.textLabel.text = [NSString stringWithFormat:@"仪表 %d ", indexPath.row-1];
    }
    
    
    return cell;
}
//背景颜色只能这里设置，不然ios6无法显示
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
//    cell.backgroundColor = [UITableView getTableViewCellColor];
}
-(void)buttonPressed{
    NewDeviceViewController *newDeviceView = [[NewDeviceViewController alloc] init];
    [self.navigationController pushViewController:newDeviceView animated:YES];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row == 4) {
        NewDeviceViewController *newDeviceView = [[NewDeviceViewController alloc] init];
        [self.navigationController pushViewController:newDeviceView animated:YES];
    }
    else{
        DeviceInfoViewController *newDeviceView = [[DeviceInfoViewController alloc] init];
        [self.navigationController pushViewController:newDeviceView animated:YES];
    }
}



@end




















